<template>
	<!-- 消息列表组件 -->
	<view class="flex align-center p-2 border-bottom border-light-secondary" hover-class="bg-light" @click="open">
		<image :src="item.avatar" style="width: 80rpx;height: 80rpx;" class="rounded-circle mr-2"></image>
		<view class="flex flex-column flex-1">
			<view class="flex align-center justify-between">
				<text class="font-md">{{item.username}}</text>
				<!--使用formatTime函数格式化时间戳-->
				<text class="font text-secondary">{{item.update_time | formatTime}}</text>
			</view>
			<view class="flex align-center justify-between">
				<text class="text-secondary text-ellipsis" style="max-width: 500rpx;">{{item.data}}</text>
				<uni-badge :text="item.noread" type="error"></uni-badge>
			</view>
		</view>
	</view>
</template>

<script>
	// 引入时间库
	import $T from '@/common/css/time.js';
	// 数字角标组件库
	import uniBadge from '@/components/uni-ui/uni-badge/uni-badge.vue'
	export default {
		components: {
			uniBadge
		},
		props: {
			item: Object,
			index: Number
		},
		// 过滤器
		filters: {
			// 格式化时间戳
			formatTime: function(value) {
				return $T.gettime(value);
			}
		},
		methods: {
			open() {
				uni.navigateTo({
					url: '../../pages/user-chat/user-chat'
				});
			}
		},
	}
</script>

<style>
</style>
